package com.example.onlinemusic.controller;

import com.example.onlinemusic.common.R;
import com.example.onlinemusic.model.request.SingerRequest;
import com.example.onlinemusic.service.SingerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 歌手管理控制层
 */
@RestController
public class SingerController {
    @Autowired
    private SingerService singerService;

    /**
     * 查询歌手列表
     *
     * @return
     */
    @GetMapping("/singer")
    public R allSinger() {
        return singerService.allSinger();
    }

    /**
     * 添加歌手
     *
     * @param singerRequest
     * @return
     */
    @PostMapping("/singer/add")
    public R addSinger(@RequestBody SingerRequest singerRequest) {
        return singerService.addSinger(singerRequest);
    }

    /**
     * 根据ID删除歌手
     * @param id
     * @return
     */
    @DeleteMapping("/singer/delete")
    public R deleteSinger(@RequestParam int id) {
        return singerService.deleteSinger(id);
    }

    /**
     * 更新歌手信息
     * @param singerRequest
     * @return
     */
    @PostMapping("/singer/update")
    public R updateSinger(@RequestBody SingerRequest singerRequest){
        return singerService.updateSinger(singerRequest);
    }

}
